import redis
import logging


class Config(object):

    # 配置sql扩展
    SQLALCHEMY_DATABASE_URI = 'mysql://root:131372@127.0.0.1/one08'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # 当请求结束时自动自动提交
    # SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 配置redis
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 配置密钥
    SECRET_KEY = 'mkPR3YQfVi5OHU1OiIBWG2D7VkLcDvmGJWKco3hnpn4='

    # 配置session扩展
    SESSION_TYPE = 'redis'
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = 3600


class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING